home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 11032 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.4 KB  |  47 lines

  1. Newsgroups: comp.lang.c
  2. Path: news.sprintlink.net!eskimo!scs
  3. From: scs@eskimo.com (Steve Summit)
  4. Subject: Re: Converting Strings to Upper Case
  5. X-Nntp-Posting-Host: eskimo.com
  6. Message-ID: <DoMIoI.9IG@eskimo.com>
  7. Sender: news@eskimo.com (News User Id)
  8. Organization: schmorganization
  9. References: <4ifra6$52i@scipio.cyberstore.ca> <DoFA24.AL7@iquest.net> <4ii1nh$bng@castle.nando.net>
  10. Date: Thu, 21 Mar 1996 15:21:53 GMT
  11.  
  12. In article <DoFA24.AL7@iquest.net>, dlmiller@iquest.net (Doug or Rose Miller)
  13. wrote:
  14. > for (p = test; *p; *p++)
  15. >     if (isalpha(*p)) *p ^= 0x20;  /* for ascii machines e.g. PC; use 0x40 for ebcdic machines e.g. IBM mainframe */
  16.  
  17. Besides the problems which Bill McCarthy has already pointed out,
  18. I wonder why you're using that needlessly machine-dependent
  19. expression?  If you're going to use isalpha() out of <ctype.h>,
  20. why not also use toupper()?
  21.  
  22. As a general rule, any time you can replace
  23.  
  24.     #ifdef machine_a
  25.     x = machine_a_dependent_expression;
  26.     #else
  27.     #ifdef machine_b
  28.     x = machine_b_dependent_expression;
  29.     #else
  30.     #error "Which machine is this?"
  31.     #endif
  32.     #endif
  33.  
  34. with
  35.  
  36.     x = portable_expression;
  37.  
  38. it's a win in my book.
  39.  
  40.                     Steve Summit
  41.                     scs@eskimo.com
  42. -- 
  43. The Communications Decency Act within the Telecommunications Act
  44. of 1996 (U.S.) is an annoying, threatening, abusive, indecent,
  45. and obscene piece of legislation which attempts to ban annoying,
  46. threatening, abusive, indecent, or obscene communication.
  47.